package com.salesystem.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import com.salesystem.dao.entity.Customer;
import com.salesystem.dao.entity.CustomerDAO;
import com.salesystem.dao.entity.Customertype;
import com.salesystem.dao.entity.Employee;
import com.salesystem.dao.interfaces.CustomerBiz;

@Service
public class CustomerImpl implements CustomerBiz {
	@Resource
	private CustomerDAO dao;

	public void addCustomer() {
		// TODO Auto-generated method stub

	}

	public void delCustomer(String cid) {
		Customer c=dao.findById(cid);
		dao.delete(c);

	}

	public List<Customer> getCusteomerList() {
		List<Customer> list=dao.findAll();
		System.out.println(list);
		return list;

	}

	public void importCustomers() {
		// TODO Auto-generated method stub

	}

	public void updateCustomer(String cid,Customer c,Customertype type) {
		Customer customer=dao.findById(cid);
		customer.setAddress(c.getAddress());
		customer.setCustomertype(type);
		customer.setEmail(c.getEmail());
		customer.setPerson(c.getPerson());
		customer.setQq(c.getQq());
		customer.setTel(c.getTel());	
		dao.attachDirty(customer);
	}

	public Customer viewCustomer(String cid) {
		Customer customer=dao.findById(cid);
		return customer;

	}

}
